﻿using System.Collections;
using System.Collections.Generic;
using IdentityServer4;
using IdentityServer4.Models;
using IdentityServer4.Test;

namespace IDSDemo.IdentityServerHost
{
    public static class Config
    {
        /// <summary>
        /// 
        /// </summary>
        public static IEnumerable<ApiScope> ApiScopes=>new List<ApiScope>()
        {
            new ApiScope("sample_api","示例项目 API")
        };

        /// <summary>
        /// 客户端
        /// </summary>
        public static IEnumerable<Client> Clients=>new Client[]
        {
            new Client()
            {
                ClientId = "sample_api",
                ClientSecrets =
                {
                    new Secret("sample_client_secret".Sha256())
                },
                AllowedGrantTypes = GrantTypes.ClientCredentials,
                AllowedScopes = {"sample_api"}
            }
            ,new Client()
            {
                ClientId = "sample_pass_client",
                ClientSecrets = { new Secret("sample_client_secret".Sha256())},
                AllowedGrantTypes = GrantTypes.ResourceOwnerPassword,
                AllowedScopes = {"sample_api"}
            }
            ,new Client()
            {

                ClientId = "sample_mvc_client",
                ClientName = "Sample MVC Client",
                ClientSecrets = { new Secret("sample_client_secret".Sha256())},
                AllowedGrantTypes = GrantTypes.Code,
                RedirectUris = {"https://localhost:4001/signin-oidc"},
                PostLogoutRedirectUris = {"https://localhost:4001/sigout-callback-oidc"},
                AllowedScopes = new List<string>()
                {
                    IdentityServerConstants.StandardScopes.OpenId,
                    IdentityServerConstants.StandardScopes.Profile
                },
                RequireConsent = true
            }
        };

        /// <summary>
        /// 用户
        /// </summary>
        public static List<TestUser> Users = new List<TestUser>()
        {
            new TestUser()
            {
                SubjectId = "1",
                Username = "admin",
                Password = "123"
            }
        };

        /// <summary>
        /// 认证资源
        /// </summary>
        public static IEnumerable<IdentityResource> IdentityResources => new List<IdentityResource>()
        {
            new IdentityResources.OpenId(),
            new IdentityResources.Profile(),
            new IdentityResources.Email()
        };
    }
}